<?php



namespace App\Http\Requests\ApiV2;

use Illuminate\Support\Facades\Auth;
use App\Services\Business\Models\MyCategory;


class VideoRecordRequest extends BaseRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'title' => 'required|max:120',

        ];
    }

    public function messages()
    {
        return [
            'title.required' => __('请输入视频标题'),
            'title.max' => __('视频标题的长度不能超过:size个字符', ['size' => 120]),

        ];
    }

    public function filldata()
    {
        $category =  MyCategory::query()->where('user_id',Auth::id())->where('is_default',1)->first();
        $categoryId  =  $category ? $category->id:0;
        return [
            'user_id'=>Auth::id(),
            'category_id' => (int)$categoryId,
            'title' => (string)$this->input('title'),
            'aliyun_video_id'=>(string)$this->input('aliyun_video_id'),
            'duration'=>(string)$this->input('duration'),


        ];
    }

}
